/**
 * Created with IntelliJ IDEA.
 * User: Thoughtworker
 * Date: 8/25/13
 * Time: 3:14 PM
 * To change this template use File | Settings | File Templates.
 */
public enum Score {
    Love {
        @Override
        public String toString(Score otherPlayersScore) {
            return "0";
        }

        @Override
        Score scorePoint(Score otherPlayersScore) {
            return Fifteen;
        }

        @Override
        Score losePoint(Score otherPlayersScore) {
            return Love;
        }
    },
    Fifteen {
        @Override
        public String toString(Score otherPlayersScore) {
            return "15";
        }

        @Override
        Score scorePoint(Score otherPlayersScore) {
            return Thirty;
        }

        @Override
        Score losePoint(Score otherPlayersScore) {
            return Fifteen;
        }
    }, Thirty {
        @Override
        public String toString(Score otherPlayersScore) {
            return "30";
        }

        @Override
        Score scorePoint(Score otherPlayersScore) {
            return Forty;
        }

        @Override
        Score losePoint(Score otherPlayersScore) {
            return Thirty;
        }
    }, Forty {
        @Override
        public String toString(Score otherPlayersScore) {
            return "40";
        }

        @Override
        Score scorePoint(Score otherPlayersScore) {
            if(otherPlayersScore == Forty) {
                return Advantage;
            }
            return Win;
        }

        @Override
        Score losePoint(Score otherPlayersScore) {
            if(otherPlayersScore == Forty) {
                return NotAdvantage;
            }
            return Forty;
        }
    }, Advantage {
        @Override
        public String toString(Score score) {
            return "Advantage";
        }

        @Override
        Score scorePoint(Score otherPlayersScore) {
            return Win;
        }

        @Override
        Score losePoint(Score otherPlayersScore) {
            return Forty;
        }
    }, NotAdvantage {
        @Override
        public String toString(Score score) {
            return " ";
        }

        @Override
        Score scorePoint(Score otherPlayersScore) {
            return Forty;
        }

        @Override
        Score losePoint(Score otherPlayersScore) {
            return Forty;
        }
    }, Win {
        @Override
        public String toString(Score score) {
            return "Win";
        }

        @Override
        Score scorePoint(Score otherPlayersScore) {
            return Win;
        }

        @Override
        Score losePoint(Score otherPlayersScore) {
            return Win;
        }
    };

    public abstract String toString(Score score);
    abstract Score scorePoint(Score otherPlayersScore);
    abstract Score losePoint(Score otherPlayersScore);
}
